<?php
/**
 * 
 * @author tangbl
 *
 */
class CommonAction extends Action {

    /**
     * 初始化方法
     */
    public function _initialize() {
		

		//exit();
    	$t     = C('VAR_TEMPLATE');
		$theme = $this->_param("$t","","");
		if(empty($theme)){
			$theme = C('DEFAULT_THEME');
		}
		if(!strpos('|'.C('THEME_LIST'),$theme)){
			$theme = C('DEFAULT_THEME');
		}
		cookie('think_template',$theme,3600);
		
		$NOW_THEME_PATH = TMPL_PATH.$theme.'/';
		$NOW_THEME_URL  = TMPL_URL .$theme.'/';
		
		$this->assign('NOW_THEME_PATH',$NOW_THEME_PATH);
		$this->assign('NOW_THEME_URL' ,$NOW_THEME_URL);
		define('NOW_THEME_NAME', $theme);
		
		$this->_checkMBAC();
    }
    
    /**
     * 检查用户操作权限
     */
    public function _checkMBAC(){
    	
    	import('@.ORG.RBAC');
        if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
			RBAC::checkLogin();
            if (!RBAC::AccessDecision()) {
                //检查认证识别号
                if (!$_SESSION [C('USER_AUTH_KEY')]) {
                    //跳转到认证网关
                    RBAC::redirect(PHP_FILE.C('USER_AUTH_GATEWAY'));
                }
                
                $this->assign('jumpUrl', PHP_FILE . C('USER_PERMISSION_GATEWAY'));
                // 提示错误信息
                $this->error(L('_VALID_ACCESS_')); 
                //redirect(PHP_FILE . C('USER_PERMISSION_GATEWAY'));
            }
        }
    }
	
	/**
	 * 定义空操作
	 */
	public function _empty(){
		
		$this->error(L('cfg_form_action_noexsits'));
	}
	
}